#include "CollisionInState.h"

using namespace std;
using namespace sf;

int delayIterator = 0;

void collisionCharacterMap(const map<int, Character*> &charMap, Vector2i &collision)
{
	


	for (auto it = charMap.begin(); it != charMap.end(); it++)
	{
		
		for (auto it2 = charMap.begin(); it2 != charMap.end(); it2++)
		{
			if (it->second->getAlive())
			{
			
				if (rectCollision(it->second->getPosition(), it->second->getSize(), it2->second->getPosition(), it2->second->getSize()))
				{
					
					if (it->first != it2->first){
						
						collision = Vector2i(it->first, it2->first);
					}

				}	

			
					

			}
		
		}
	}
}






void collisionBulletMap(const map<int, Character*> &charMap, Vector3i &collision)
{

	

	for (auto it :charMap) //dans characterMap
	{
			
		
		for (auto it2: it.second->getBulletManager().getBulletMap()) //dans bulletMap
		{
			
			for (auto it3:charMap) //dans characterMap
			{			

				if (it2.second->getIsShooting())
					{
					if (rectCollision(it3.second->getPosition(), it3.second->getSize(), it2.second->getPosition(), it2.second->getSize()))
					{	
						 collision = Vector3i(it3.first, it2.first, it.first); //recois  -- bullet  -- tire								
					}
					
				}

				
			}
		}
	}
}